package com.ghp.admin.config;


import com.ghp.auth.AuthConfig;
import com.ghp.auth.config.GiteeAuthConfig;
import com.ghp.auth.config.GithubAuthConfig;
import com.ghp.auth.config.QqAuthConfig;
import com.ghp.auth.config.WeiboAuthConfig;
import com.ghp.auth.enums.scope.GiteeAuthScope;
import com.ghp.auth.enums.scope.GithubAuthScope;
import com.ghp.auth.enums.scope.QqAuthScope;
import com.ghp.auth.enums.scope.WeiboAuthScope;
import com.ghp.auth.utils.AuthScopeUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Scope;

/**
 * @author ghp
 * @title
 * @description
 */
@Configuration
@Import(AuthConfig.class)
// TODO 将 xxx 替换成你自己的配置
public class AuthLoginConfig {

    /**
     * 构建 Gitee 登录配置
     *
     * @return
     */
    @Bean(name = "gitee")
    @Scope("singleton")
    public GiteeAuthConfig buildGiteeAuthConfig() {
        return GiteeAuthConfig.builder().clientId("xxx")
                .clientSecret("xxx")
                .redirectUri("xxx")
                // 配置权限
                .scopes(AuthScopeUtils.getScopes(GiteeAuthScope.USER_INFO))
                .build();
    }

    /**
     * 构建 GitHub 登录配置
     *
     * @return
     */
    @Bean(name = "github")
    @Scope("singleton")
    public GithubAuthConfig buildGitHubAuthConfig() {
        return GithubAuthConfig.builder().clientId("xxx")
                .clientSecret("xxx")
                .redirectUri("xxx")
                // 配置权限
                .scopes(AuthScopeUtils.getScopes(GithubAuthScope.USER))
                // 配置代理
                .httpProxyConfig(new HttpProxyConfig("xxx", xxx))
                .build();
    }


    /**
     * 构建 QQ 登录配置
     *
     * @return
     */
    @Bean(name = "qq")
    @Scope("singleton")
    public QqAuthConfig buildQQAuthConfig() {
        return QqAuthConfig.builder().clientId("xxx")
                .clientSecret("xxx")
                .redirectUri("xxx")
                // 配置权限
                .scopes(AuthScopeUtils.getScopes(QqAuthScope.GET_USER_INFO))
                .build();
    }

    /**
     * 构建 微博 登录配置
     *
     * @return
     */
    @Bean(name = "weibo")
    @Scope("singleton")
    public WeiboAuthConfig buildWeiBoAuthConfig() {
        return WeiboAuthConfig.builder().clientId("xxx")
                .clientSecret("xxx")
                .redirectUri("xxx")
                // 配置权限
                .scopes(AuthScopeUtils.getScopes(WeiboAuthScope.ALL))
                .build();
    }

}
